<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/iconfont.css">
		<style>
			a{color:#000000;}
			.mui-content-padded{margin:5px 0 0 0;}
			.mui-row-list span{float: left; line-height:33px; width:20%;}
			.mui-row-list select{float: left; line-height:14px; font-size:14px; margin-top:2px; margin-left: 5px;}
			.mui-btn-block{margin-bottom:0; padding:6px;}
			.mui-col-sm-12{ border-top: 1px solid #D1D1D1; width:100%; padding-top:5px; font-size:14px;}
			input[type="text"]{height:30px; margin-bottom: 5px;}
			form:before{ background: none !important; border: none !important;}
			.nav-dh{width:100%; height:50px; position: fixed; bottom:0px; left:0px; background-color: #FFFFFF;}
			.nav-dh-left{  width: 45%; margin-top: 5px; margin:0 0.5rem; height:40px; float: left; line-height:40px; text-align:center; background-color:#007AFF; border-radius:10px; color: #FFFFFF;}
			.nav-dh-right{ width: 45%; margin-top: 5px; margin:0 0.5rem; height:40px; float: right; line-height:40px; text-align:center; background-color:#EC971F; border-radius:10px; color: #FFFFFF;}
			.user{text-align:center; background-color: #ffffff;margin-bottom: 10px; padding: 10px;}
			.user b{margin-right: 10px; color: #007aff; line-height: 32px; font-size: 16px; font-family: "微软雅黑";}
			.user a{margin-right: 10px; color: #000000; line-height: 32px; font-size: 16px; font-family: "微软雅黑";}
			.content{background: #ffffff; margin:10px 0; padding: 0;}
			.content-cell{padding:15px;}
			.content-text{font-size: 16px; height: 30px; line-height: 30px;}
			.content-text b{font-size: 16px; line-height: 16px; color: #007aff;}
			.iconfont{color: #007AFF; font-size: 24px; line-height: 30px; margin-right: 10px;}
			.mui-icon-list{color: #007AFF; font-size: 24px; line-height: 30px; margin-right: 10px;}
			.with30{ width: 28%; margin-top: 15px; margin:0 0.5rem; height:40px; float: left; line-height:40px; text-align:center; background-color:#007AFF; border-radius:10px; color: #FFFFFF;}
			.with30:nth-child(3){ background-color:#EC971F;}
			.with20{ width: 20%;  margin:0.3rem 0.5rem 0 0.5rem; height:40px; float: left; line-height:40px; text-align:center; background-color:#007AFF; border-radius:10px; color: #FFFFFF;}
			.with10{ width: 23%;  margin:0.3rem 0.2rem 0 0.2rem; height:40px; float: left; line-height:40px; text-align:center; background-color:#007AFF; border-radius:10px; color: #FFFFFF;}
			.with30:nth-child(3){ background-color:#EC971F;}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" id="follow_up_id">患者基本信息</h1>
		</header>
		<div class="mui-conten" style="margin-top:53px;">
			<div style="width:98%; margin: 0 auto; padding-bottom: 45px;">
					<div class="mui-content-padded">
						<div class="user">
							<span class="mui-icon mui-icon-contact" style="font-size:45px; color: #007AFF;"></span>
							<span><b id="name"></b><a id="sex"></a><a id="age"></a></span>
						</div>
						<div id="item1mobile" class="mui-control-content mui-active">
							<ul class="content">
								<li class="content-cell">
									<div class="content-text"><span class="mui-icon icon iconfont">&#xe621;</span><b>基本信息</b></div>
									<div class="content-text"><span style="width:7rem; float: left;">健康档案号:</span><a id="ehrCode"></a></div>
									<div class="content-text"><span style="width:7rem; float: left;">身份证号:</span><a id="idCard"></a></div>
									<div class="content-text"><span style="width:7rem; float: left;">医保号:</span><a id="nhCode"></a></div>
									<div class="content-text"><span style="width:7rem; float: left;">家庭地址:</span><a id="homeAddress"></a></div>
								</li>
							</ul>
							<ul class="mui-table-view content" id="hists"> 
								<li class="mui-table-view-cell mui-collapse">
									<a class="mui-navigate-right" href="#">
										<span class="mui-icon mui-icon-list" style="font-size:18px;"></span>
										<b>历史随访</b>
										<p style="color:#CCCCCC">显示最近6个月的随访信息</p>
									</a>
									<div class="mui-collapse-content" style="margin: 0; padding: 0;" id="history">
										
									</div>
								</li>
							</ul>
							<ul class="mui-table-view content" id="histl"> 
								<li class="mui-table-view-cell mui-collapse">
									<a class="mui-navigate-right" href="#">
										<span class="mui-icon mui-icon-list" style="font-size:18px;"></span>
										<b>历史生活自理</b>
									</a>
									<div class="mui-collapse-content" style="margin: 0; padding: 0;" id="oneself">
										
									</div>
								</li>
							</ul>
							<ul class="mui-table-view content" id="histc"> 
								<li class="mui-table-view-cell mui-collapse">
									<a class="mui-navigate-right" href="#">
										<span class="mui-icon mui-icon-list" style="font-size:18px;"></span>
										<b>历史中医体质</b>
									</a>
									<div class="mui-collapse-content" style="margin: 0; padding: 0;" id="chidoc">
										
									</div>
								</li>
							</ul>
						</div>
					</div>
			</div>
			<!--导航页面-->
			<div class="nav-dh">
				<div class="nav-dh-left" id="follow_up_button" onClick="high()"></div>
				<div class="nav-dh-right" onClick="follow_add()">新增随访</div>
			</div>
		</div>
		<script src="../js/mui.js"></script>
		<script src="../js/jquery.min-1.11.1.js"></script>
		<script src="../js/request.js"></script>
		<script type="text/javascript">
			window.addEventListener('refresh', function(e){//执行刷新
				location.reload();
			});
			//获取变量
			var date1 = new Date();
			var year1=date1.getFullYear(); 
			var month1=date1.getMonth()+1;
			var day1=date1.getDate();
				month1 =(month1<10 ? "0"+month1:month1); 
				day1 =(day1<10 ? "0"+day1:day1); 
				endDate = (year1.toString()+'-'+month1.toString()+'-'+day1.toString());

			var date2 = new Date();
      			date2.setMonth(date2.getMonth()-6);
			var year2=date2.getFullYear(); 
			var month2=date2.getMonth()+1;
			var day2=date2.getDate();
				month2 =(month2<10 ? "0"+month2:month2); 
				day2 =(day2<10 ? "0"+day2:day2); 
				beginDate = (year2.toString()+'-'+month2.toString()+'-'+day2.toString());

			var symname = "";
			var nextTime = "";
			var rows = new Array;
			var listdata = "";
			var arcid = "";
			var visitId = null;
			var queryType = "";
			mui.plusReady(function(){
				var self = plus.webview.currentWebview();
				if(self.name == "老年人"){
					var headname = 中医体质
				}else if(self.name == "孕产妇"){
					var headname = "产后访视"
				}else{
					var headname = self.name +'专档'
				}
				console.log(self.name,"用户类型")
				listdata = self.data;
				var selfdata = JSON.parse(listdata);
				console.log(selfdata,"用户信息")
				symname = headname;
				if(symname == "中医体质"){
					$("#histl").show();
					$("#histc").show();
				}else{
					$("#histl").hide();
					$("#histc").hide();
				}	
				if(symname == "高血压专档"){
					queryType = "1"
					mui.ajax(getRequestUrl.url+'/mobile/ehr/Hypertension/get',{
						data:{
							"ehr_id":selfdata.ehrId
						},
						dataType:'json',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						timeout:10000,//超时时间设置为10秒；
						success:function(data){
							var rows = data.rows[0];
							console.log(rows.nextTime)
							if (data.status == 1) {
								arcid = rows.id;
								nextTime = rows.nextTime;
							} else {
								
							}
						},
						error:function(xhr,type,errorThrown){
							
						}
					});	
				}else if(symname == "糖尿病专档"){
					queryType = "2"
					mui.ajax(getRequestUrl.url+'/mobile/ehr/Diabetes/get',{
						data:{
							"ehr_id":selfdata.ehrId
						},
						dataType:'json',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						timeout:10000,//超时时间设置为10秒；
						success:function(data){
							var rows = data.rows[0];
							if (data.status == 1) {
								arcid = rows.id;
								nextTime = rows.nextTime;
							} else {
								
							}
						},
						error:function(xhr,type,errorThrown){
							
						}
					});	
				}else if(symname == "肺结核专档"){
					queryType = "3"
					mui.ajax(getRequestUrl.url+'/mobile/ehr/Tb/get',{
						data:{
							"ehr_id":selfdata.ehrId
						},
						dataType:'json',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						timeout:10000,//超时时间设置为10秒；
						success:function(data){
							var rows = data.rows[0];
							var datat = JSON.stringify(rows)
							if (data.status == 1) {
								arcid = rows.tbId;
								nextTime = rows.nextTime;
							} else {
								
							}
						},
						error:function(xhr,type,errorThrown){
							
						}
					});	
				}else if(symname == "中医体质"){
					$("#follow_up_button").before("<div class='with30' onClick='high(1)'>生活自理</div>");
					$(".nav-dh").children("div").removeClass("nav-dh-left").addClass("with30");
					queryType = "4"
					mui.ajax(getRequestUrl.url+'/mobile/ehr/Oldster/get',{
						data:{
							"ehr_id":selfdata.ehrId
						},
						dataType:'json',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						timeout:10000,//超时时间设置为10秒；
						success:function(data){
							var rows = data.rows[0];
							var datat = JSON.stringify(rows)
							if (data.status == 1) {
								nextTime = rows.nextTime;
							} else {
								
							}
						},
						error:function(xhr,type,errorThrown){
							
						}
					});	
					//生活自理
					mui.ajax(getRequestUrl.url+'/mobile/ehr/OldpeopleAssess/getVisitDetail',{
						data:{
							"id": "0",
							"ehr_id": selfdata.ehrId
						},
						dataType:'json',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						timeout:10000,//超时时间设置为10秒；
						success:function(data){
							rows = data.rows;
							var oneself = "";
							if (data.status == 1) {
								for(var i=0; i<rows.length; i++){
									var date0 = new Date(rows[i].createDate);
									var year0=date0.getFullYear(); 
									var month0=date0.getMonth()+1;
									var day0=date0.getDate();
										month0 =(month0<10 ? "0"+month0:month0); 
										day0 =(day0<10 ? "0"+day0:day0); 
										visitDate = (year0.toString()+'-'+month0.toString()+'-'+day0.toString());	
									oneself += '<li class="mui-table-view-cell" onclick="editor('+data.rows[i].id+')">'
													+'<div class="content-text"><span style="width:7rem; float: left;">随访日期:</span>'+visitDate+'</div>'
													+'<div class="content-text"><span style="width:7rem; float: left;">自理情况:</span>'+rows[i].result+'</div>'
													+'<div class="content-text"><span style="width:7rem; float: left;">随访医生:</span>'+rows[i].doctorName+'</div>'
												+'</li>';
								}
							} else {
								alert(data.message);
							}
							$("#oneself").prepend(oneself);
						},
						error:function(xhr,type,errorThrown){
							
						}
					});
					//中医体质
					mui.ajax(getRequestUrl.url+'/mobile/ehr/OldpeopleZyAssess/getVisitDetail',{
						data:{
							"id": "0",
							"ehr_id": selfdata.ehrId
						},
						dataType:'json',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						timeout:10000,//超时时间设置为10秒；
						success:function(data){
							rows = data.rows;
							var chidoc = "";
							if (data.status == 1) {
								for(var i=0; i<rows.length; i++){
									var date0 = new Date(rows[i].createDate);
									var year0=date0.getFullYear(); 
									var month0=date0.getMonth()+1;
									var day0=date0.getDate();
										month0 =(month0<10 ? "0"+month0:month0); 
										day0 =(day0<10 ? "0"+day0:day0); 
										visitDate = (year0.toString()+'-'+month0.toString()+'-'+day0.toString());	
									chidoc += '<li class="mui-table-view-cell" onclick="editor('+data.rows[i].id+')">'
													+'<div class="content-text"><span style="width:7rem; float: left;">随访日期:</span>'+visitDate+'</div>'
													+'<div class="content-text"><span style="width:7rem; float: left;">随访医生:</span>'+rows[i].doctorName+'</div>'
												+'</li>';
								}
							} else {
								alert(data.message);
							}
							$("#chidoc").prepend(chidoc);
						},
						error:function(xhr,type,errorThrown){
							
						}
					});
				}else if(symname == "精神病专档"){
					queryType = "5"
					mui.ajax(getRequestUrl.url+'/mobile/ehr/psychosisVisitRecord/getVisitDetail',{
						data:{
							"ehr_id":selfdata.ehrId
						},
						dataType:'json',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						timeout:10000,//超时时间设置为10秒；
						success:function(data){
							var rows = data.rows[0];
							var datat = JSON.stringify(rows)
							if (data.status == 1) {
								arcid = rows.tbId;
								nextTime = rows.nextTime;
							} else {
								
							}
						},
						error:function(xhr,type,errorThrown){
							
						}
					});	
				}else if(symname == "产后访视"){
					$("#follow_up_button").before("<div class='with20' onClick='high(3)'>产前随访</div>");
					$("#follow_up_button").before("<div class='with20' onClick='high(4)'>产前2-5</div>");
					$("#follow_up_button").after("<div class='with20' onClick='high(5)'>产后42天</div>");
					$("#follow_up_button").siblings(".nav-dh-right").remove();
					$(".nav-dh").children("div").removeClass("nav-dh-left").addClass("with20");
					queryType = "6"
				}else if(symname == "儿童健康专档"){
					$("#follow_up_button").before("<div class='with10' onClick='high(6)'>新生儿</div>");
					$("#follow_up_button").before("<div class='with10' onClick='high(7)'>1岁以内</div>");
					$("#follow_up_button").after("<div class='with10' onClick='high(8)'>1-2岁</div><div class='with20' onClick='high(9)'>3-6岁</div>");
					$("#follow_up_button").siblings(".nav-dh-right").remove();
					$("#follow_up_button").remove();
					$(".nav-dh").children("div").removeClass("nav-dh-left").addClass("with10");
					queryType = "7"
				}
				if(symname != "儿童健康专档"){
					document.getElementById("follow_up_button").innerHTML = headname;	
				}
				var date0 = new Date(selfdata.birthday);
				var date1 = new Date();
				var year0=date0.getFullYear(); 
				var year1=date1.getFullYear(); 
				var patage = year1-year0;
				document.getElementById("name").innerHTML = selfdata.name;
				document.getElementById("sex").innerHTML = selfdata.sex;
				document.getElementById("age").innerHTML = patage;
				document.getElementById("ehrCode").innerHTML = selfdata.ehrCode;
				document.getElementById("idCard").innerHTML = selfdata.idCard;
				document.getElementById("nhCode").innerHTML = selfdata.nhCode;
				document.getElementById("homeAddress").innerHTML = selfdata.homeAddress;
				mui.ajax(getRequestUrl.url+'/mobile/IntegratedQuery/getVisitRecord',{
				 	data:{
				 		"queryType": queryType,
				 		"beginDate": beginDate,
				 		"endDate": endDate,
				 		"idCard": "",
				 		"patientName": selfdata.name
				 	},
				 	dataType:'json',//服务器返回json格式数据
				 	type:'post',//HTTP请求类型
				 	timeout:10000,//超时时间设置为10秒；
				 	success:function(data){
				 		rows = data.rows;
				 		var listcont = "";
				 		if (data.status == 1) {
				 			for(var i=0; i<rows.length; i++){
				 				var date0 = new Date(rows[i].visitDate);
				 				var year0=date0.getFullYear(); 
				 				var month0=date0.getMonth()+1;
				 				var day0=date0.getDate();
				 					month0 =(month0<10 ? "0"+month0:month0); 
				 					day0 =(day0<10 ? "0"+day0:day0); 
				 					visitDate = (year0.toString()+'-'+month0.toString()+'-'+day0.toString());
				 				var visitWay = "";
				 				if(rows[i].visitWay == "1" || rows[i].visitWay == "621"){
				 					visitWay = "门诊"
				 				}else if(rows[i].visitWay == "2" || rows[i].visitWay == "622"){
				 					visitWay = "家庭"
				 				}else if(rows[i].visitWay == "3" || rows[i].visitWay == "623"){
				 					visitWay = "电话"
				 				}	
				 				listcont += '<li class="mui-table-view-cell" onclick="editor('+data.rows[i].visitId+')">'
				 								+'<div class="content-text"><span style="width:7rem; float: left;">随访日期:</span>'+visitDate+'</div>'
				 								+'<div class="content-text"><span style="width:7rem; float: left;">随访方式:</span>'+visitWay+'</div>'
				 								+'<div class="content-text"><span style="width:7rem; float: left;">随访医生:</span>'+rows[i].doctorName+'</div>'
				 							+'</li>';
				 			}
				 		} else {
				 			alert(data.message);
				 		}
				 		$("#history").prepend(listcont);
				 	},
				 	error:function(xhr,type,errorThrown){
				 		
				 	}
				});
			})
			
			//添加随访
			function follow_add(){
				mui.openWindow({
					url: 'follow_up_add.html', 
					id:'follow_up_add',
					extras:{
						symname: symname,
						data:listdata,
						arcid:arcid,
						nextTime:nextTime,
						visitId:visitId
					}
				});
			}
			//专档按钮
			function high(bottom_name){
				if(symname != "儿童健康专档"){
					var high_name = document.getElementById("follow_up_button").innerHTML;
					var age = document.getElementById("age").innerHTML;
				}
				if(high_name == "高血压专档"){
					mui.openWindow({
						url: 'high.html', 
						id:'high',
						extras:{
							data:listdata
						}
					});
				}else if(high_name == "糖尿病专档"){
					mui.openWindow({
						url: 'diabetes.html', 
						id:'diabetes',
						extras:{
							data:listdata
						}
					});
				}else if(high_name == "肺结核专档"){
					mui.openWindow({
						url: 'tuberculosis.html', 
						id:'tuberculosis',
						extras:{
							data:listdata,
							age:age
						}
					});
				}else if(high_name == "精神病专档"){
					mui.openWindow({
						url:'psychosis/Special.html', 
						id:'Special',
						extras:{
							data:listdata,
							age:age
						}
					});
				}else if(bottom_name == 1){
					mui.openWindow({
						url: 'elderly/life_power.html', 
						id:'tuberculosis',
						extras:{
							data:listdata,
							age:age
						}
					});
				}else if(bottom_name == 2){
					mui.openWindow({
						url: 'elderly/life_power.html', 
						id:'tuberculosis',
						extras:{
							data:listdata,
							age:age
						}
					});
				}else if(bottom_name == 3){
					mui.openWindow({
						url: 'maternal/maternal_list.html', 
						id:'maternal_list',
						extras:{
							data:listdata,
							name:"产前随访",
							visitLevel:1
						}
					});
				}else if(bottom_name == 4){
					mui.openWindow({
						url: 'maternal/maternal_list.html', 
						id:'maternal_list',
						extras:{
					 		data:listdata,
							name:"产前2-5次随访",
							visitLevel:2
						}
					});
				}else if(bottom_name == 5){
					mui.openWindow({
						url: 'maternal/maternal_list.html', 
						id:'maternal_list',
						extras:{
					 		data:listdata,
							name:"产后42天检查",
							visitLevel:4
						}
					});
				}else if(high_name == "产后访视"){
					mui.openWindow({
						url: 'maternal/maternal_list.html', 
						id:'maternal_list',
						extras:{
					 		data:listdata,
							name:"产后访视",
							visitLevel:3
						}
					});
				}else if(bottom_name == 6){
					mui.openWindow({
						url:'children/children_list.html', 
						id:'children_list',
						extras:{
					 		data:listdata,
							name:"新生儿",
							visitLevel:1
						}
					});
				}else if(bottom_name == 7){
					mui.openWindow({
						url:'children/children_list.html', 
						id:'children_list',
						extras:{
					 		data:listdata,
							name:"1岁以内",
							visitLevel:2
						}
					});
				}else if(bottom_name == 8){
					mui.openWindow({
						url:'children/children_list.html', 
						id:'children_list',
						extras:{
					 		data:listdata,
							name:"1～2岁",
							visitLevel:3
						}
					});
				}else if(bottom_name == 9){
					mui.openWindow({
						url:'children/children_list.html', 
						id:'children_list',
						extras:{
					 		data:listdata,
							name:"3～6岁",
							visitLevel:4
						}
					});
				}else if(high_name == "中医体质"){
					mui.openWindow({
						url: 'elderly/physical.html', 
						id:'physical',
						extras:{
							data:listdata,
							age:age
						}
					});
				}else if(high_name == "基本信息专档"){
					mui.openWindow({
						url: 'info/info.html',
						id:'info',
						extras:{
							data:listdata,
							age:age
						}
					});
				}
			}
			//编辑随访页面
			function editor(vid){
				visitId = vid;
				mui.openWindow({
					url: 'follow_up_add.html', 
					id:'follow_up_add',
					extras:{
						symname: symname,
						data:listdata,
						arcid:arcid,
						nextTime:nextTime,
						visitId:visitId
					}
				});
			}
		</script>
	</body>

</html>